#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   75644-install.sh
# Version:    1.0
# Date:       2013/12/19
# Author:     yuanhui.shi
# Email:      yuanhui.shi@cs2c.com.cn
# Summary:    03系统安全功能-01SELinux-03SELinux重要命令-03SELinux安全上下文标签相关命令-08install
# Notes:      安全上下文标签 install
# Copyright:  China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/12/19
#             -   The first one
# ----------------------------------------------------------------------

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh
source ../../lib/XmlParse.sh
source ./lib/Selib.sh

function CleanData ()
{
  rm -rf /tmp/test 
  rm -rf /root/file-install
  rm -rf /mnt/file-install
  EchoInfo "75644-install.sh执行完毕"
}

trap "CleanData" EXIT
CheckSElinuxStatus

mkdir /tmp/test
touch /root/file-install

SELINUX_CONTEXT=`ls --scontext /root/file-install | cut -d " " -f1`

install -P /root/file-install /tmp/test

[ "`ls --scontext /tmp/test/file-install |cut -d " " -f1`" == "$SELINUX_CONTEXT" ]
EchoResult "/tmp/test/file-install保留了源文件的安全上下文信息"

install -Z system_u:object_r:mnt_t:s0 /root/file-install /mnt
[ "`ls --scontext /mnt/file-install |cut -d " " -f1`"  == "system_u:object_r:mnt_t:s0" ]
EchoResult "install -Z 命令可以指定安全上下文信息"
